package cn.ydt.ydt.qrcode.controller;

import cn.ydt.ydt.common.resful.JsonPage;
import cn.ydt.ydt.common.resful.JsonResult;
import cn.ydt.ydt.pojo.community.model.QrCode;
import cn.ydt.ydt.pojo.work.vo.WorkDetailsVO;
import cn.ydt.ydt.pojo.work.vo.WorkSimpleVO;
import cn.ydt.ydt.qrcode.service.IQrService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "/code", produces = "application/json; charset=utf-8")
public class QrController {
    @Autowired
    private IQrService iQrService;

    @PostMapping("/createQr")
    @ApiOperation(value = "增加二维码")
    public JsonResult<Void> createQr() {
        iQrService.addNewQrCode();
        return JsonResult.ok("创建二维码成功！");
    }

    @GetMapping("/getByCommunityId")
    @ApiOperation(value = "查询一个二维码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "communityId", value = "社区id", paramType = "path", required = true, dataType = "Long")
    })
    public JsonResult<QrCode> getByQrId() {
        return JsonResult.ok(iQrService.selectQr(), "查询成功！");
    }

    /**
     * 根据二维码id查询类别列表
     */
//    @ApiOperation(value = "根据qrId查询类别列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "page", value = "页码默认第一页", dataType = "int"),
//            @ApiImplicitParam(name = "pageSize", value = "每页记录数默认20", dataType = "int")
//    })
//    @GetMapping("/list-by-qrcode")
//    public JsonResult<JsonPage<QrCode>> listByQr(
//            @RequestParam(required = false, defaultValue = WebConst.DEFAULT_PAGE) Integer page,
//            @RequestParam(required = false, defaultValue = WebConst.DEFAULT_PAGE_SIZE) Integer pageSize) {
//        JsonPage<QrCode> qrcodeList = iQrService.listByQr(page,pageSize);
//        return JsonResult.ok(qrcodeList);
//    }

}
